/**
 * @file /include/gui/main_window.hpp
 *
 * @brief Qt based gui for gui.
 *
 * @date November 2010
 **/
#ifndef gui_MAIN_WINDOW_H
#define gui_MAIN_WINDOW_H

/*****************************************************************************
** Includes
*****************************************************************************/

#include <QMainWindow>
#include "ui_main_window.h"
#include "include/gui/ui_data.h"
#include "include/led/led_node.h"
#include "include/gui/alarmshow.h"
#include "include/gui/redecode.h"
#include "qnode.hpp"
#include <QTimer>
#include <QDateTime>

#include <QtNetwork/QHostInfo>
#include <QtNetwork/QNetworkInterface>
#include <QtNetwork/QHostAddress>
#include <QDesktopServices>
#include <QUrl>

#include <QCoreApplication>
#include <QDir>

/*****************************************************************************
** Namespace
*****************************************************************************/

namespace gui {

/*****************************************************************************
** Interface [MainWindow]
*****************************************************************************/
/**
 * @brief Qt central, all operations relating to the view part here.
 */
class MainWindow : public QMainWindow {
Q_OBJECT

public:
	MainWindow(int argc, char** argv, QWidget *parent = 0);
	~MainWindow();

  struct GetPara{
      QString IPpb;
      QString ServerIP;
      QString LedScreenIP;
      QString LedWord;
      int LedStatus;
      int CarTypeMode;
      int SensorStatus;
      int LedOpenCloseMode;
      int PositionMode;
  };

  QLabel *MyMotor[MOTOR_NUM];
  QToolButton *MyMotorBnt[MOTOR_NUM];
  int *alarmFlag[MOTOR_NUM];

public Q_SLOTS:
	/******************************************
	** Auto-connections (connectSlotsByName())
	*******************************************/
    void MainWindowClose();
    void on_Close_clicked();
    void ScreenGetReady();               //是否是预设程序
    void MotorBntSet(void);
    bool LogDirExist(QString fullPath);  //添加自动创建log文件夹

    //qnode send
    void ScreenOperateDataInfoSend();
    void quick_fixed_position_send_();
    void SendArmOpenFun(int num);
    void SendArmCloseFun(int num);
    void SendRebootAgvFun();
    void SendArmOpenCloseStopFun(int num);
    void SendErrorMaskSysFun();
    void Mytimer_change();//定时器
    int GetSensorPara();
    void RobotParaShow();
    int setSensorStatus(uint8_t num);
    void showSystemBtn();

    void on_ChangeType1_clicked();
    void on_ChangeType2_clicked();
    void on_ChangeType3_clicked();
    void on_ChangeType4_clicked();

    //qnode recieve
    void BatteryDecode();
    void PcNetStatusDecode();
    void PcAgvScreenComStatus();
    void IODecode();
    void PcInfoDecode();
    void PcRobotStatusRunDecode();
    void ArmRunInfoDecode();
    void MotorInfoDecode();
    void MissionInfoDecode();
    void MechanicalParametersDecode();
    void AgvSwStateDecode();
    void GyroInfoDecode();
    void SelfTaskInfoDecode();
    void RemoteControlReDecde();
    void EcolineInfoReDecode();

//    void on_LoadingBtn_clicked(); //完成任务按钮
//    void on_DischargeBtn_clicked(); //取消任务按钮
    void on_RebootAgv_pressed();  //机器人重启按钮
    void on_RebootAgv_released();  //机器人重启按钮
    void errorLocalLogInfoDecode(QString alarminfo);//本机错误log

    void on_Mainwindowshow_clicked();//主界面显示
    void on_Alarm_clicked();
    void on_Parametershow_clicked();
    void on_System_clicked();
    void on_BatteryParashow_clicked();
    void on_MotorReturn_clicked();
    void on_BatteryReturn_clicked();
    void on_DebugShow_clicked();
    void on_MotorParashow_clicked();
    void on_DebugReturn_clicked();
    void Robot_Base_Data_Show();//主界面显示
    void Alarmchange();//警报显示
    void ParameterChange();//传感器状态显示
    void System_Show();//系统界面显示
    void BatteryInfoShow();//电池信息界面显示
    void MotorParaChange();//电机信息界面显示

    void on_NumberCount_pressed();
    void on_NumberCount_released();
//    void on_ImpactControlOpen_clicked();
//    void on_ImpactControlClose_clicked();

    void on_ArmOpenBtn_pressed();
    void on_ArmOpenBtn_released();
    void on_ArmCloseBtn_pressed();
    void on_ArmCloseBtn_released();
    void on_ArmOpenCloseStopBtn_pressed();
    void on_ArmOpenCloseStopBtn_released();
   
    void on_OpenNet_pressed();
    void on_OpenNet_released();

    void GetParaFromJson();
    void GetParaFromJsonPosition();                 //获取定位点数据
    void LedScreenShow(uint8_t *word_txt);
    void ledTask();
    void taskNameShow();
    int  SetLedStatus(uint8_t num, uint8_t cartype);
    void AlarmHandle();
    void ButtonStyle();
    void showCarTypeBtn();
    void CarTypeModeParaChange();
private:
	Ui::MainWindowDesign ui;
	QNode qnode;
  QTimer MyTimer;
  ReDecode MyRedecode;

//  AutoShow MyAutoShow;
//  AlarmShow MyAlarmShow;

  int traffic;
  int nav_obstacle;
  int attitude_obstacle;
  int network;
  int floyd_fail;
  int local_status;
  int motro_alarm_status[5];
  int motro_alarm_status_last[5];
  AlarmShow MyAlarmShow;

  void inittimerr();

Q_SIGNALS:
    void AlarmWaining(int i);
private Q_SLOTS:
    void on_LedRealtimeOpenBtn_pressed();
    void on_LedRealtimeOpenBtn_released();
    void on_LedCustomizOpenBtn_pressed();
    void on_LedCustomizOpenBtn_released();
    void on_LedCloseBtn_pressed();
    void on_LedCloseBtn_released();
    void ReceivePara();
    void on_CancelPosition_pressed();
    void on_CancelPosition_released();
    void on_FixPosition_pressed();
    void on_FixPosition_released();
    void on_CancelTask_pressed();
    void on_CancelTask_released();
    void on_ManualBrake_pressed();
    void on_ManualBrake_released();
    void on_ManualRecover_pressed();
    void on_ManualRecover_released();
    void on_MotorParashow_Ma_clicked();
    void on_LoadingBtn_clicked();
    void on_DischargeBtn_clicked();
    void on_FixPosition_2_pressed();
    void on_FixPosition_2_released();
    void on_FixPosition_3_pressed();
    void on_FixPosition_3_released();
    void on_FixPosition_4_pressed();
    void on_FixPosition_4_released();
    void on_FixPosition_5_pressed();
    void on_FixPosition_5_released();
    void on_ArmPushBtn_pressed();
    void on_ArmPushBtn_released();
    void on_ArmPullBtn_pressed();
    void on_ArmPullBtn_released();
    void on_ArmPullPushBtn_pressed();
    void on_ArmPullPushBtn_released();
    void on_ArmPutBtn_pressed();
    void on_ArmGetBtn_released();
    void on_ArmPutBtn_released();
    void on_ArmPutGetBtn_pressed();
    void on_ArmPutGetBtn_released();
    void on_ArmGuradGetBtn_pressed();
    void on_ArmGuradGetBtn_released();
    void on_ArmGuradPutBtn_pressed();
    void on_ArmGuradPutBtn_released();
    void on_ArmGuradGetPutBtn_pressed();
    void on_ArmGuradGetPutBtn_released();
    void on_ArmGetBtn_pressed();
    void on_MotorParashow_Semi_clicked();
    void on_MotorReturn_Semi_clicked();
    void on_MotorParashow_2_Cotton_clicked();
    void on_FixPosition_6_pressed();
    void on_FixPosition_6_released();
    void on_FixPosition_7_pressed();
    void on_FixPosition_7_released();
    void on_FixPosition_8_pressed();
    void on_FixPosition_8_released();
    void on_FixPosition_9_pressed();
    void on_FixPosition_9_released();
    void on_FixPosition_10_pressed();
    void on_FixPosition_10_released();
    void on_FixPosition_11_pressed();
    void on_FixPosition_11_released();
    void on_FixPosition_12_pressed();
    void on_FixPosition_12_released();
    void on_FixPosition_13_pressed(); //叉车第1定位点
    void on_FixPosition_13_released();
    void on_FixPosition_14_released();
    void on_FixPosition_14_pressed();
    void on_FixPosition_15_pressed();
    void on_FixPosition_15_released();
    void on_FixPosition_16_pressed();
    void on_FixPosition_16_released();
    void on_FixPosition_17_pressed();
    void on_FixPosition_17_released();
    void on_ImpactControl_Cotton_clicked();
    void on_ImpactControl_2_Cotton_clicked();
    void on_OpenNet_2_pressed();
    void on_OpenNet_2_released();
    void on_LightBtn_Cotton_clicked();
    void on_ChargingOpen_Cotton_pressed();
    void on_ChargingOpen_Cotton_released();
    void on_ChargingClose_Cotton_pressed();
    void on_ChargingClose_Cotton_released();
    void on_SaftyRadar11_Cotton_pressed();
    void on_SaftyRadar11_Cotton_released();
    void on_SaftyRadar21_Cotton_pressed();
    void on_SaftyRadar21_Cotton_released();
    void on_CarTypeBSMotor5_clicked();
    void on_CarTypeBSMotor6_clicked();
    void on_CarTypeCXMotor4_clicked();
    void on_CarTypeMBmotor3_clicked();
    void on_CarTypeBZDMotor6_clicked();
    void on_CarTypeDCXMotor3_clicked();
    void on_pushButton_clicked();
    void on_LightBtn_fork_clicked();
    void on_FanControlOpen1_pressed();
    void on_FanControlOpen1_released();
    void on_FanControlClose1_pressed();
    void on_FanControlClose1_released();
    void on_FanControlOpen2_pressed();
    void on_FanControlOpen2_released();
    void on_FanControlClose2_pressed();
    void on_FanControlClose2_released();
    void on_FanControlOpen3_pressed();
    void on_FanControlOpen3_released();
    void on_FanControlClose3_pressed();
    void on_FanControlClose3_released();
    void on_FanControlOpenAll_pressed();
    void on_FanControlOpenAll_released();
    void on_FanControlCloseAll_pressed();
    void on_FanControlCloseAll_released();
};

}  // namespace gui

#endif // gui_MAIN_WINDOW_H
